﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiarySocial.Models;

namespace DiarySocial.ViewModels
{
    public class VMFactory
    {
        public static ICollection<CommentVM> commentModelToCommentVM(IEnumerable<Comment> comments)
        {
            ICollection<CommentVM> list = new HashSet<CommentVM>();
            foreach (var comment in comments)
            {
                list.Add(new CommentVM()
                {
                    Id = comment.CommentId,
                    Text = comment.Text,
                    Time = comment.Created,
                    CommentAuthor = new AuthorVM(comment.Author.UserName)
                });
            }
            return list;
        }
    }
}
